<template>
  <div>
    <div class="d-flex">
      <div class="three">
        <head-title title="平台入驻用户" :bg-numb="1"/>
        <ul class="d-flex justify-content-between">
          <li v-for="(item, index) in platform.joinOrganization" :key="index">
            <div class="record-item">
              <div class="logo">
                <img :src="require(`../assets/img/bigScreenNew/enter-${index + 1}.png`)">
              </div>
              <div class="white-color font-18 letter-spacing-1 title">{{ platformName[item.organType] }}</div>
              <div class="sum">
                <span>{{item.num}}</span>
                <small>个</small>
              </div>
            </div>
          </li>
        </ul>
      </div>
      <div class="two">
        <head-title title="平台入驻用户" :bg-numb="2"/>
        <ul class="d-flex justify-content-between">
          <li v-for="(item, index) in platform.business" :key="index">
            <div class="record-item">
              <div class="logo">
                <img :src="require(`../assets/img/bigScreenNew/business-${index + 1}.png`)">
              </div>
              <div class="white-color font-18 letter-spacing-1 title">{{item.name}}</div>
              <div class="sum">
                <span>{{item.num}}</span>
                <small>万</small>
              </div>
            </div>
          </li>
        </ul>
      </div>
    </div>
    <div class="chain">
      <head-title title="链上数据" :bg-numb="3"/>
      <swiper :options="swiperOptions" ref="mySwiper" class="history">
        <template v-for="(item, index) in blockData">
          <swiper-slide>
            <div class="firm-item" :class="[index === 1 && 'none', swiperIndex + 9 === index && 'noActive']">
              <div class="radius before"></div>
              <div class="title" :class="index === swiperIndex && 'active'">{{item.name}}</div>
              <div class="radius after"></div>
            </div>
          </swiper-slide>
        </template>
      </swiper>
      <div class="line"></div>
      <div class="block vivify " :class="[`__item __item-${index + 1}`, visibility && 'block-visible']" v-for="(item, index) in blockChain">
        <div class="title">
          <div>
            <img :src="require(`../assets/img/bigScreenNew/block-${item.key}.png`)">
            <p>{{ item.name }}</p>
          </div>
        </div>
        <div class="content">
          <div class="line"></div>
          <p v-for="child in item.data">
            <span>{{child.label}}：</span>
            <span>{{child.value}}</span>
          </p>
        </div>
      </div>
    </div>
  </div>
</template>


<script>
const organizationTypeName = {
  1: '企业方',
  2: '金融机构',
  3: '评估机构',
  4: '平台运营',
  5: '知识产权局',
  6: '知识产权促进中心'
}

import Sum from './sum.json'
import HeadTitle from '../components/HeadTitle'
import {swiper, swiperSlide} from 'vue-awesome-swiper'
import ChainSwiper from './chainSwiper'
import {filterKey} from './key_filter'
export default {
  name: "LeftView",
  mixins: [ChainSwiper],
  data() {
    const that = this
    return {
      timer: null,
      platform: Sum,
      platformName: organizationTypeName,
      visibility: false,
      swiperIndex: 0,
      swiperOptions: {
        loop: false,
        autoplay: {
          delay: 1000 * 10,
          disableOnInteraction: false
        },
        stopOnLastSlide: true,
        slidesPerView: 8,
        initialSlide: 0,
        disableOnInteraction: false,
        direction: 'vertical',//水平(horizontal)或垂直(vertical)。
        observer: true,
        observeParents: false,
        on: {
          // eslint-disable-next-line no-unused-vars
          slideChangeTransitionEnd(data) {
            that.swiperIndex = this.activeIndex
          }
        },
      },
      blockChain: []
    }
  },
  beforeDestroy() {
    this.timer && clearImmediate(this.timer)
  },
  watch: {
    swiperIndex() {
      // 走一次触发一次
      this.blockChain = filterKey(this.blockData[this.swiperIndex])
      this.visibility = false
      this.timer && clearImmediate(this.timer)
      this.timer = setTimeout(() => {
        this.visibility = true
      }, 0)
    }
  },
  components: {
    HeadTitle,
    Swiper: swiper,
    SwiperSlide: swiperSlide
  }
}
</script>

<style lang="scss">
$blockChainTop: 80px;
$blockChainLeft: 0px;
@import "../assets/css/gobal";


@mixin chainTitleBottom() {
  .title::before {
    bottom: -10px;
  }

  .content .line {
    top: -60px;
    left: 50%;
    margin-left: -8px;
  }

}

@mixin chainTitleTop() {
  .title::before {
    top: -10px;
  }

  .content .line {
    top: 165px;
    left: 50%;
    margin-left: 3px;
  }

}

.three {
  position: relative;
  padding: 0 20px;
  width: 491px;
  height: 236px;
  background-image: url("../assets/img/bigScreenNew/three.png");
  background-repeat: no-repeat;
}

.two {
  position: relative;
  box-sizing: border-box;
  padding: 0 24px;
  margin-left: 10px;
  width: 375px;
  height: 236px;
  background-image: url("../assets/img/bigScreenNew/two.png");
  background-repeat: no-repeat;
}

.record-item {
  box-sizing: border-box;
  margin-top: 60px;
  padding-top: 15px;
  width: 155px;
  height: 142px;
  background-image: url("../assets/img/bigScreenNew/record-content.png");
  text-align: center;

  .title {
    margin: 10px 0;
  }

  .sum {
    color: #30d7e1;

    span {
      font-size: 22px;
      font-weight: 550;
    }
  }
}

.chain {
  position: relative;
  width: 912px;
  height: 645px;
  background-image: url("../assets/img/bigScreenNew/chain-bg.png");
  background-repeat: no-repeat;
  .history {
    position: absolute;
    left: 18px;
    top: 80px;
    width: 178px;
    height: 540px;
    .firm-item {
      position: relative;
      &.noActive:before {
        display: none;
      }
      &:before {
        position: absolute;
        left: 50%;
        top: -100px;
        margin-left: -1px;
        content: "";
        display: block;
        width: 2px;
        height: 33px;
        background-color: #68d8fe;
      }
      &.none:before {
        display: none;
      }
      &.close:after {
        display: none;
      }
      .radius {
        position: absolute;
        z-index: 99999;
        left: 50%;
        margin-left: -2px;
        width: 4px;
        height: 4px;
        background-color: #68d8fe;
        border-radius: 50%;

        &.before {
          top: -1px;
        }

        &.after {
          top: 33px;
        }
      }

      .title {
        width: 100%;
        height: 37px;
        line-height: 37px;
        font-size: 13px;
        color: #94e0fc;
        text-align: center;
        background-image: url("../assets/img/bigScreenNew/firm.png");
        background-repeat: no-repeat;
        @include text-overflow();
        &.active {
          color: #30d7e1;
          width: 178px;
          height: 37px;
          background-image: url("../assets/img/bigScreenNew/firm-active.png");
        }
      }
    }
  }
  .line {
    position: absolute;
    left: 225px;
    top: 70px;
    width: 2px;
    height: 520px;
    background-color: #9bc1e0;
  }

  .block {
    position: absolute;
    .title {
      position: relative;
      width: 129px;
      height: 111px;
      font-size: 14px;
      color: #30d7e1;
      background-image: url("../assets/img/bigScreenNew/block-title.png");
      background-repeat: no-repeat;
      > div {
        text-align: center;
        @include absoluteCenter();
        p {
          margin-top: 10px;
        }
      }
      &:before {
        position: absolute;
        z-index: 999;
        left: 50%;
        margin-left: -3px;
        content: "";
        display: block;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background-color: #24c5ff;
      }
    }
    .content {
      position: relative;
      box-sizing: border-box;
      padding: 8px;
      width: 193px;
      height: 164px;
      border: solid 1px #3f88ad;
      border-left-color: #66d4fa;
      border-top-left-radius: 9px;
      border-bottom-right-radius: 9px;
      .line {
        position: absolute;
        width: 2px;
        height: 60px;
        background-color: #68d8fe;
      }
      p {
        font-size: 13px;
        color: #fefefe;
        word-break: break-all;
        margin-bottom: 4px;
        &:last-child {
          margin-bottom: 0;
        }
      }
      &:before {
        position: absolute;
        top: -2px;
        left: -2px;
        content: "";
        width: 22px;
        height: 11px;
        background-image: url("../assets/img/bigScreenNew/before.png");
      }
      &:after {
        position: absolute;
        right: -2px;
        bottom: -2px;
        content: "";
        width: 75px;
        height: 11px;
        background-image: url("../assets/img/bigScreenNew/after.png");
      }
    }
    &.__item-1 {
      @include chainTitleBottom();
      top: 170px + $blockChainTop;
      left: 290px;
      .title {
        left: $blockChainLeft;
      }
      .content {
        position: absolute;
        top: 180px;
        left: -25px;
      }
    }

    &.__item-2 {
      @include chainTitleTop();
      top: 170px + $blockChainTop;
      left: 395px;
      .title {
        position: absolute;
        top: 56px;
        left: 0 + $blockChainLeft;
      }
      .content {
        position: absolute;
        top: -180px;
        left: -36px;
      }
    }

    &.__item-3 {
      @include chainTitleBottom();
      top: 170px + $blockChainTop;
      left: 501px;
      .title {
        left: $blockChainLeft;
      }
      .content {
        position: absolute;
        top: 180px;
        left: -25px;
      }
      &:before {
        left: 50%;
        bottom: -70px;
        margin-left: -1px;
      }
    }

    &.__item-4 {
      @include chainTitleTop();
      top: 170px + $blockChainTop;
      left: 605px;
      .title {
        position: absolute;
        top: 56px;
        left: 0 + $blockChainLeft;
      }
      .content {
        position: absolute;
        top: -180px;
        left: -36px;
      }
      &:before {
        left: 65px;
        top: -14px;
        margin-left: -1px;
      }
    }

    &.__item-5 {
      @include chainTitleBottom();
      top: 170px + $blockChainTop;
      left: 710px;
      .title {
        left: $blockChainLeft;
      }
      .content {
        position: absolute;
        top: 180px;
        left: -25px;
      }
      &:before {
        left: 50%;
        bottom: -70px;
        margin-left: -1px;
      }
    }
  }
}

</style>
<style lang="scss">
@import "chain-history";
</style>
